/* 
 * Copyright [2018] [Alex/libo(liboms@hotmail.com)]
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.aop.handler.reflection;

import java.lang.reflect.Method;
import java.util.logging.Logger;

import com.hyts.aop.annotation.Ignore;
import com.hyts.aop.handler.base.ValidateMethod;

/**
 * @title RoundAopHandler.java
 * @package com.hyts.aop.handler.java
 * @author libo/Alex
 * @email liboms@hotmail.com/liboware@163.com
 * @date 2018年4月25日
 * @version V1.0
 */
public class ValidateMethodHandler extends ValidateMethod{

	/**
	 * <p>
	 * {字段的描述}
	 * </p>
	 * 
	 * @fieldName logger
	 * @fieldType Logger
	 */
	Logger logger = Logger.getLogger(ValidateMethodHandler.class.getName());

	private Method[] methods;

	private Object proxyRealObject;

	/**
	 * @constructor：BeforeMethodHandler
	 * @param proxyRealObject
	 */
	public ValidateMethodHandler(Object proxyRealObject) {
		this.methods = proxyRealObject.getClass().getMethods();
		this.proxyRealObject = proxyRealObject;
	}

	/**
	 * IllegalAccessException @throws IllegalArgumentException @throws
	 * InvocationTargetException @exception
	 */
	public boolean validate(Method method){
	    for (int i = 0; i < methods.length; i++) {
            if (method.getName().equals(methods[i].getName())) {
                if (!methods[i].isAnnotationPresent(Ignore.class)) {
                   return true;
                }
            }
        }
        return false;
	}
}
